/*
 * Math.cpp
 *
 *  Created on: 10.05.2010
 *      Author: 123
 */
#include "sMath.h"
float abs(float x) {
	float result;

	__asm__ volatile (
			"mtv      %1, S000\n"
			"vabs.s   S000, S000\n"
			"mfv      %0, S000\n"
			: "=r"(result) : "r"(x));

	return result;
}
float MathFloor(float x) {
	float result;

	__asm__ volatile (
			"mtv      %1, S000\n"
			"vf2id.s  S000, S000, 0\n"
			"vi2f.s	  S000, S000, 0\n"
			"mfv      %0, S000\n"
			: "=r"(result) : "r"(x));

	return result;
}
void MathSincos(float r, float *s, float *c) {
	__asm__ volatile (
			"mtv      %2, S002\n"
			"vcst.s   S003, VFPU_2_PI\n"
			"vmul.s   S002, S002, S003\n"
			"vrot.p   C000, S002, [s, c]\n"
			"mfv      %0, S000\n"
			"mfv      %1, S001\n"
			: "=r"(*s), "=r"(*c): "r"(r));
}

